<template>
	<view id="engineeringDetail">
		<view class="engineer-tit">项目信息</view>
		<u-gap height="8" bgColor="#f5f6fa"></u-gap>
		<view class="list">
			<text>项目全称：{{ projectList.projectName }}</text>
			<text>项目类型：{{ projectList.projectType }}</text>
			<text>项目编号：{{ projectList.projectNo }}</text>
			<text>项目地址：{{ projectList.projectAddress }}</text>
			<text>项目经理：{{ projectList.constructorContacts }}</text>
			<text>联系电话：{{ projectList.constructorTel }}</text>
			<text>项目简介：--</text>
			<!-- <text>项目简介：{{ projectList.projectInfo }}</text> -->
		</view>
		<u-gap height="8" bgColor="#f5f6fa"></u-gap>
		<view>
			<text class="title-text">五方人员信息</text>
			<view class="people-box">
				<view class="people-detail">
					<text class="unit">建设单位</text>
					<text class="company">{{ projectList.constructorName }}</text>
					<view class="detail">
						<view class="detail-in">
							<image lazyLoad :showLoading="true" src="https://bc-staticfiles.oss-cn-zhangjiakou.aliyuncs.com/wechat/user_icon.png" mode="aspectFill"></image>
							<text>{{ projectList.constructorContacts }}</text>
						</view>
						<view class="detail-in">
							<image lazyLoad :showLoading="true" src="https://bc-staticfiles.oss-cn-zhangjiakou.aliyuncs.com/wechat/phone_icon.png" mode="aspectFill"></image>
							<text>{{ projectList.constructorTel }}</text>
						</view>
						<view class="detail-in detail-in-click" @tap="call(projectList.constructorTel)">拨打电话</view>
					</view>
				</view>
				<view class="people-detail">
					<text class="unit">施工单位</text>
					<text class="company">{{ projectList.builderName }}</text>
					<view class="detail">
						<view class="detail-in">
							<image lazyLoad :showLoading="true" src="https://bc-staticfiles.oss-cn-zhangjiakou.aliyuncs.com/wechat/user_icon.png" mode="aspectFill"></image>
							<text>{{ projectList.builderContacts }}</text>
						</view>
						<view class="detail-in">
							<image lazyLoad :showLoading="true" src="https://bc-staticfiles.oss-cn-zhangjiakou.aliyuncs.com/wechat/phone_icon.png"  mode="aspectFill"></image>
							<text>{{ projectList.builderTel }}</text>
						</view>
						<view class="detail-in detail-in-click" @tap="call(projectList.builderTel)">拨打电话</view>
					</view>
				</view>
				<view class="people-detail">
					<text class="unit">监理单位</text>
					<text class="company">{{ projectList.jldw }}</text>
					<view class="detail">
						<view class="detail-in">
							<image lazyLoad :showLoading="true" src="https://bc-staticfiles.oss-cn-zhangjiakou.aliyuncs.com/wechat/user_icon.png" mode="aspectFill"></image>
							<text>{{ projectList.jldwFzr }}</text>
						</view>
						<view class="detail-in">
							<image lazyLoad :showLoading="true" src="https://bc-staticfiles.oss-cn-zhangjiakou.aliyuncs.com/wechat/phone_icon.png" mode="aspectFill"></image>
							<text>{{ projectList.jldwDh }}</text>
						</view>
						<view class="detail-in detail-in-click" @tap="call(projectList.jldwDh)">拨打电话</view>
					</view>
				</view>
				<view class="people-detail">
					<text class="unit">设计单位</text>
					<text class="company">{{ projectList.sjdw }}</text>
					<view class="detail">
						<view class="detail-in">
							<image lazyLoad :showLoading="true" src="https://bc-staticfiles.oss-cn-zhangjiakou.aliyuncs.com/wechat/user_icon.png" mode="aspectFill"></image>
							<text>{{ projectList.sjdwFzr }}</text>
						</view>
						<view class="detail-in">
							<image lazyLoad :showLoading="true" src="https://bc-staticfiles.oss-cn-zhangjiakou.aliyuncs.com/wechat/phone_icon.png" mode="aspectFill"></image>
							<text>{{ projectList.sjdwDh }}</text>
						</view>
						<view class="detail-in detail-in-click" @tap="call(projectList.sjdwDh)">拨打电话</view>
					</view>
				</view>
				<view class="people-detail">
					<text class="unit">勘察单位</text>
					<text class="company">{{ projectList.kcdw }}</text>
					<view class="detail">
						<view class="detail-in">
							<image lazyLoad :showLoading="true" src="https://bc-staticfiles.oss-cn-zhangjiakou.aliyuncs.com/wechat/user_icon.png" mode="aspectFill"></image>
							<text>{{ projectList.kcdwFzr }}</text>
						</view>
						<view class="detail-in">
							<image lazyLoad :showLoading="true" src="https://bc-staticfiles.oss-cn-zhangjiakou.aliyuncs.com/wechat/phone_icon.png" mode="aspectFill"></image>
							<text>{{ projectList.kcdwDh }}</text>
						</view>
						<view class="detail-in detail-in-click" @tap="call(projectList.kcdwDh)">拨打电话</view>
					</view>
				</view>
			</view>
			<!-- <u-empty mode="data" icon="http://cdn.uviewui.com/uview/empty/data.png"></u-empty> -->
		</view>
	</view>
</template>

<script>
	import {
	 getProjectIndexId
	} from '@/api/global'
	import config from '@/utils/defaultConfig'
	
	export default {
		data () {
			return {
				projectId: '',
				projectList: {},
				projectTypeOpts: [
					config.projectType
				],
			}
		},
		onLoad(options){
			this.projectId = options.id;
			getProjectIndexId(this.projectId).then(res => {
				this.projectList = res.data.data
				for (const k in this.projectList) {
					if (this.projectList[k] === null || this.projectList[k] ===undefined || this.projectList[k] === '') {
						this.projectList[k] = '--'
					}
				}
				if (this.projectList.projectType === '0') {
					// this.projectList.projectType = this.projectTypeOpts[0][0].title
					this.projectList.projectType = '房建'
				} else if (this.projectList.projectType === '1') {
					this.projectList.projectType = '轨道'
				} else if (this.projectList.projectType === '2') {
					this.projectList.projectType = '市政'
				} else if (this.projectList.projectType === '3') {
					this.projectList.projectType = '园林'
				} else if (this.projectList.projectType === '4') {
					this.projectList.projectType = '拆迁'
				} else {
					this.projectList.projectType = '其他'
				}
			})
		},
		methods: {
			// 拨打电话
			call(phone) {
				console.log('传入的电话',phone);
				//uni.makePhoneCall({
					// 	  phoneNumber:phone,
					// 	success(){
					// 		console.log('拨打成功了');
					// 	},
					// 	fail() {
					// 		console.log('拨打失败了');
					// 	}
					// })
				const res = uni.getSystemInfoSync();
				// ios系统默认有个模态框
				if(res.platform=='ios'){
					uni.makePhoneCall({
					phoneNumber:phone,
					success(){
						// console.log('拨打成功了');
					},
					fail() {
						// console.log('拨打失败了');
					}
				})
				}else{
				//安卓手机手动设置一个showActionSheet
					uni.showActionSheet({
						itemList: [phone,'呼叫'],
						success:function(res){
							// console.log(res);
							if(res.tapIndex==1){
								uni.makePhoneCall({
									phoneNumber: phone,
								})
							}
						}
					})
				}
			}
		}
	}
</script>

<style lang="scss" scoped>
	#engineeringDetail {
		height: 100vh;
		.engineer-tit {
			height: 90upx;
			line-height: 90upx;
			font-size: 34upx;
			font-weight: 500;
			text-align: center;
		}
		.title-text {
			display: block;
			font-size: 30upx;
			margin-top: 26upx;
			margin-left: 26upx;
		}
		.list {
			padding: 4upx 30upx;
			color: gray;
			text {
				display: block;
				padding: 24upx 0;
			}
		}
	}
	.people-box {
		padding: 20upx;
		.people-detail {
			display: flex;
			flex-direction: column;
			border-bottom: 2px solid $uni-bg-color-hover;
			padding: 20upx 0;
			.unit {
				width: 140upx;
				// line-height: 60upx;
				background-color: rgba(0, 170, 255, 0.1);
				color: $uni-color-primary;
				padding: 6upx 0;
				text-align: center;
			}
			.company {
				padding: 16upx 0;
			}
			.detail {
				display: flex;
				// flex-direction: row;
				justify-content: space-between;
				line-height: 36upx;
				.detail-in {
					display: flex;
					flex-direction: row;
					image {
						width: 36upx;
						height: 36upx;
					}
					text {
						padding-left: 8upx;
					}
				}
				.detail-in-click {
					color: $uni-color-primary;
				}
			}
		}
	}

</style>